
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-body">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="row">
                            <div class="col-lg-8">
                                <strong>Danh sách Đại lý cấp 1</strong>
                            </div>
                           
                             <div class="col-lg-2 pull-right">
                            <form method="POST" action="<?php echo $this->baseUrl()?>/admin/report1/export">
                                    <button class="btn btn-primary" id="submit">Xuất excel</button>   
                            </form>
                        </div>
                        </div>
                        
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row">            
            <div class="panel-body">
                <div class="table-reponsive">
                    <div id="jqxgrid">

                    </div>
                </div>
            </div>    
</div>
    <script type="text/javascript">
        $(document).ready(function () {
            // prepare the data
            var source =
            {
                datatype: "json",
                datafields:
                [
                    { name: 'id',type:'int'},
                    { name: 'name', type: 'string' },
                    { name: 'province_name', type: 'string'},
                    { name: 'representavie', type: 'string'},
                    {name:'legal_capital',type:'number'},
                    {name:'experience',type:'string'},
                    {name:'birthday',type:'string'},
                    {name:'ability_agent',type:'string'},
                    {name:'person',type:'string'},
                    {name:'ability_archive',type:'string'},
                    {name:'ability_transport',type:'string'}
                ],
                url:'<?php echo $this->baseUrl() ?>/admin/report1/service',
                sortcolumn: 'id',
                sortdirection: 'asc'
               
            };
         var dataAdapter = new $.jqx.dataAdapter(source, {
                loadComplete: function () {
                }
            });
            var cellsrenderer = function (row, column, value) {
                return '<div style="text-align: left; margin-top: 5px;">&nbsp' +value + '</div>';
            };            
            $("#jqxgrid").jqxGrid(
            {
                width: '100%',
                source: dataAdapter,  
                theme: 'bootstrap',
                pageable: true,
                showfilterrow: true,
                filterable: true,
                autoheight: true,
                sortable: true,
                altrows: true,
                enabletooltips: true,
                selectionmode: 'multiplecellsadvanced',
                columnsResize: true,
                rendergridrows: function (params) {
                    return params.data;
                },                
                ready: function () {
                    $("#jqxgrid").jqxGrid('hideColumn', 'id');                   
                },
                columns: [
                  {text:'id',dataField:'id',width:0},
                  { text: 'KV bán hàng', cellsrenderer: cellsrenderer ,editable: false, dataField: 'province_name', width: '25%' },
                  { text: 'Đai lý cấp 1', cellsrenderer: cellsrenderer ,editable: false, dataField: 'name', width: '25%' },
                  { text: 'Người đại diện', cellsrenderer: cellsrenderer , editable: false, dataField: 'representavie', width: '15%' },
                  { text: 'Năm sinh', cellsrenderer: cellsrenderer , editable: false, dataField: 'birthday', width: '15%'},
                  { text: 'Vồn điều lệ', cellsrenderer: cellsrenderer ,cellsformat:'c2', editable: false, dataField: 'legal_capital', width: '10%' },
                  { text: 'Kinh nghiệm KDPB', cellsrenderer: cellsrenderer , editable: false, dataField: 'experience', width: '15%' },
                  { text: 'Năng lực tiêu thụ', cellsrenderer: cellsrenderer , editable: false, dataField: 'ability_agent', width: '15%' },
                  { text: 'Số lượng CBKD', cellsrenderer: cellsrenderer , editable: false, dataField: 'person', width: '15%' },
                  { text: 'Năng lực kho chứa', cellsrenderer: cellsrenderer , editable: false, dataField: 'ability_archive', width: '15%' },
                  { text: 'Năng lực vận tải', cellsrenderer: cellsrenderer , editable: false, dataField: 'ability_transport', width: '15%' },
                ]
            });
           
        });
    </script>
<!--    <script type="text/javascript">
        $('#submit').click(function(){
            $.post("<?php echo $this->baseUrl()?>/admin/report1/export",null,function(data){
                alert("Xuất excel thành công");
            })
        });
    </script>
        -->
    
